package cn.funnyxb.tools.appFrame.util;

import android.content.Context;
import android.content.res.AssetManager;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.channels.FileChannel;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class FileTool
{
  public static boolean Ectract(String paramString1, String paramString2)
  {
    int i;
    try
    {
      FileInputStream localFileInputStream = new FileInputStream(paramString1);
      ZipInputStream localZipInputStream = new ZipInputStream(localFileInputStream);
      byte[] arrayOfByte = new byte[8192];
      File localFile1;
      File localFile2;
      while (true)
      {
        ZipEntry localZipEntry = localZipInputStream.getNextEntry();
        if (localZipEntry == null)
        {
          localFileInputStream.close();
          localZipInputStream.close();
          i = 1;
          break label192:
        }
        localFile1 = new File(paramString2 + localZipEntry.getName());
        localFile2 = new File(localFile1.getParentFile().getPath());
        if (!(localZipEntry.isDirectory()))
          break;
        if (!(localFile1.exists()))
          localFile1.mkdirs();
        localZipInputStream.closeEntry();
      }
      if (!(localFile2.exists()))
        localFile2.mkdirs();
      FileOutputStream localFileOutputStream = new FileOutputStream(localFile1);
      while (true)
      {
        int j = localZipInputStream.read(arrayOfByte);
        if (j == -1)
        {
          localZipInputStream.closeEntry();
          localFileOutputStream.close();
        }
        localFileOutputStream.write(arrayOfByte, 0, j);
      }
      label192: return i;
    }
    catch (Exception localException)
    {
      i = 0;
    }
  }

  public static boolean copyFileFromAssets(Context paramContext, String paramString1, String paramString2, String paramString3)
    throws IOException
  {
    if (paramString3 == null)
      paramString3 = paramString1;
    InputStream localInputStream = paramContext.getAssets().open(paramString1);
    new File(paramString2).mkdirs();
    FileOutputStream localFileOutputStream = new FileOutputStream(paramString2 + paramString3);
    byte[] arrayOfByte = new byte[1024];
    while (true)
    {
      int i = localInputStream.read(arrayOfByte);
      if (i <= 0)
      {
        localFileOutputStream.flush();
        localFileOutputStream.close();
        localInputStream.close();
        return true;
      }
      localFileOutputStream.write(arrayOfByte, 0, i);
    }
  }

  public static boolean reorganization(String paramString, int paramInt)
  {
    FileChannel localFileChannel;
    FileChannel[] arrayOfFileChannel;
    String[] arrayOfString;
    int j;
    long l1;
    int k;
    try
    {
      localFileChannel = new FileOutputStream(paramString).getChannel();
      arrayOfFileChannel = new FileChannel[paramInt];
      arrayOfString = new String[paramInt];
      j = 0;
      if (j >= paramInt)
      {
        l1 = 0L;
        k = 0;
        label143: label62: if (k < paramInt)
          break label143;
      }
    }
    catch (FileNotFoundException localFileNotFoundException1)
    {
      int i;
      try
      {
        localFileChannel.close();
        int l = 0;
        if (l >= paramInt)
        {
          i = 1;
          while (true)
            while (true)
            {
              while (true)
              {
                return i;
                localFileNotFoundException1 = localFileNotFoundException1;
                localFileNotFoundException1.printStackTrace();
                i = 0;
                continue;
                try
                {
                  arrayOfString[j] = paramString + "_" + (j + 1);
                  arrayOfFileChannel[j] = new FileInputStream(arrayOfString[j]).getChannel();
                  ++j;
                }
                catch (FileNotFoundException localFileNotFoundException2)
                {
                  localFileNotFoundException2.printStackTrace();
                  i = 0;
                }
              }
              continue;
              try
              {
                long l2 = localFileChannel.transferFrom(arrayOfFileChannel[k], l1, arrayOfFileChannel[k].size());
                l1 += l2;
                ++k;
              }
              catch (IOException localIOException1)
              {
                localIOException1.printStackTrace();
                i = 0;
              }
            }
        }
        arrayOfFileChannel[l].close();
        ++l;
      }
      catch (IOException localIOException2)
      {
        localIOException2.printStackTrace();
        i = 0;
        break label62:
      }
    }
  }

  public static void segmentation(String paramString, int paramInt)
  {
    if (!(new File(paramString).exists()))
      label14: return;
    Object localObject = null;
    label33: String[] arrayOfString;
    FileChannel[] arrayOfFileChannel;
    int i;
    try
    {
      FileChannel localFileChannel = new FileInputStream(paramString).getChannel();
      localObject = localFileChannel;
      arrayOfString = new String[paramInt];
      arrayOfFileChannel = new FileChannel[paramInt];
      i = 0;
      label54: label64: label74: if (i < paramInt);
    }
    catch (IOException localIOException1)
    {
      long l1;
      long l2;
      int j;
      try
      {
        long l6 = localObject.size();
        l1 = l6;
        l2 = l1 / paramInt;
        j = 0;
        if (j < paramInt);
      }
      catch (IOException localIOException1)
      {
        try
        {
          while (true)
          {
            localObject.close();
            for (int k = 0; ; ++k)
            {
              if (k < paramInt);
              arrayOfFileChannel[k].close();
            }
            localFileNotFoundException1 = localFileNotFoundException1;
            localFileNotFoundException1.printStackTrace();
            break label33:
            try
            {
              arrayOfString[i] = paramString + "_" + (i + 1);
              arrayOfFileChannel[i] = new FileOutputStream(arrayOfString[i]).getChannel();
              ++i;
            }
            catch (FileNotFoundException localFileNotFoundException2)
            {
              localFileNotFoundException2.printStackTrace();
            }
          }
          break label54:
          localIOException1 = localIOException1;
          localIOException1.printStackTrace();
          l1 = 0L;
          break label64:
          long l3 = l2 * j;
          long l5;
          if (j == paramInt - 1)
            l5 = paramInt;
          try
          {
            long l4 = l2 + l1 % l5;
            localObject.transferTo(l3, l4, arrayOfFileChannel[j]);
            ++j;
            break label74:
            l4 = l2;
          }
          catch (IOException localIOException2)
          {
            localIOException2.printStackTrace();
          }
        }
        catch (IOException localIOException3)
        {
          localIOException3.printStackTrace();
          break label14:
        }
      }
    }
  }

  // ERROR //
  public static boolean turnInputStream2File(InputStream paramInputStream, String paramString)
    throws IOException
  {
    // Byte code:
    //   0: new 32	java/io/File
    //   3: dup
    //   4: aload_1
    //   5: invokespecial 55	java/io/File:<init>	(Ljava/lang/String;)V
    //   8: astore_2
    //   9: aload_2
    //   10: invokevirtual 157	java/io/File:isFile	()Z
    //   13: ifne +9 -> 22
    //   16: iconst_0
    //   17: istore 12
    //   19: iload 12
    //   21: ireturn
    //   22: aload_2
    //   23: invokevirtual 69	java/io/File:exists	()Z
    //   26: ifeq +8 -> 34
    //   29: aload_2
    //   30: invokevirtual 160	java/io/File:delete	()Z
    //   33: pop
    //   34: aload_2
    //   35: invokevirtual 72	java/io/File:mkdirs	()Z
    //   38: pop
    //   39: aconst_null
    //   40: astore 4
    //   42: new 77	java/io/FileOutputStream
    //   45: dup
    //   46: aload_2
    //   47: invokespecial 80	java/io/FileOutputStream:<init>	(Ljava/io/File;)V
    //   50: astore 5
    //   52: sipush 2048
    //   55: newarray byte
    //   57: astore 10
    //   59: aload_0
    //   60: aload 10
    //   62: invokevirtual 109	java/io/InputStream:read	([B)I
    //   65: istore 11
    //   67: iload 11
    //   69: ifgt +19 -> 88
    //   72: aload 5
    //   74: ifnull +8 -> 82
    //   77: aload 5
    //   79: invokevirtual 85	java/io/FileOutputStream:close	()V
    //   82: iconst_1
    //   83: istore 12
    //   85: goto -66 -> 19
    //   88: aload 5
    //   90: aload 10
    //   92: iconst_0
    //   93: iload 11
    //   95: invokevirtual 89	java/io/FileOutputStream:write	([BII)V
    //   98: goto -39 -> 59
    //   101: astore 8
    //   103: aload 8
    //   105: astore 9
    //   107: aload 5
    //   109: astore 4
    //   111: aload 9
    //   113: invokevirtual 146	IOException:printStackTrace	()V
    //   116: aload 9
    //   118: athrow
    //   119: astore 6
    //   121: aload 4
    //   123: ifnull +8 -> 131
    //   126: aload 4
    //   128: invokevirtual 85	java/io/FileOutputStream:close	()V
    //   131: aload 6
    //   133: athrow
    //   134: astore 7
    //   136: aload 7
    //   138: invokevirtual 146	IOException:printStackTrace	()V
    //   141: goto -10 -> 131
    //   144: astore 13
    //   146: aload 13
    //   148: invokevirtual 146	IOException:printStackTrace	()V
    //   151: goto -69 -> 82
    //   154: astore 6
    //   156: aload 5
    //   158: astore 4
    //   160: goto -39 -> 121
    //   163: astore 14
    //   165: aload 14
    //   167: astore 9
    //   169: goto -58 -> 111
    //
    // Exception table:
    //   from	to	target	type
    //   52	67	101	IOException
    //   88	98	101	IOException
    //   42	52	119	finally
    //   111	119	119	finally
    //   126	131	134	IOException
    //   77	82	144	IOException
    //   52	67	154	finally
    //   88	98	154	finally
    //   42	52	163	IOException
  }
}

/* Location:           E:\Desktop\复件 classes_dex2jar.jar
 * Qualified Name:     cn.funnyxb.tools.appFrame.util.FileTool
 * JD-Core Version:    0.5.3
 */